<template>
  <el-dialog
    :model-value="visible"
    width="50%"
    top="50px"
    title="预览"
    @close="handleCancel"
    center
  >
    <GenForm ref="genForm" v-if="visible" :formData="formData" />
    <!-- <EgTimelineParallelTodo/> -->
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="handleCancel">取消</el-button>
        <el-button type="primary" @click="subFlow()"> 提交 </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>
import GenForm from "../../components/FlowDesign/FlowForm/form-generate/gen-form.vue";
import { flowStart } from "../../api/flow.js";
// import EgTimelineParallelTodo from "./EgTimelineParallelTodo.vue";
import { ref, toRefs } from "vue";
/* ts类型定义区域 */
const formData = ref({});
const genForm = ref(null);
/* 定义数据区域 */
const props = defineProps(["visible", "flowId"]);
const { flowId } = toRefs(props);
//   visible: boolean
// }>()
const emits = defineEmits(["cancel"]);
/* 事件处理区域 */
const handleCancel = () => {
  emits("cancel");
};

const subFlow = () => {
  let data = {
    flowId: flowId.value,
    formData: formData.value,
  };
  flowStart(data).then((res) => {
    console.log("提交数据结束------------res>", JSON.stringify(res));
    handleCancel();
  });
  //genForm.value.getData();
  // console.log("flowId:", flowId);
  // console.log(JSON.stringify(formData.value));
};
/* 监听 */

/* 生命周期 */
</script>

<style scoped>
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
